import request from '@/api/request'

// 获取用户列表
export function requestUserList(info, data) {
  return request({
    method: 'post',
    url: `/admin/sysAuth/user/findUsersByPage/${info.start}/${info.limit}`,
    data
  })
}

// 获取用户详情
export function requesttUserInfo(id) {
  return request({
    method: 'get',
    url: `/admin/sysAuth/user/${id}`
  })
}

// 删除用户
export function deleteUser(id) {
  return request({
    method: 'delete',
    url: `/admin/sysAuth/user/removeUser/${id}`
  })
}

// 新增用户
export function addUser(data) {
  return request({
    method: 'post',
    url: `/admin/sysAuth/user/saveUserRoles`,
    data
  })
}

//  更新用户
export function updataUser(data) {
  return request({
    method: 'put',
    url: `/admin/sysAuth/user/updateUserRoles`,
    data
  })
}

// 获取角色列表
export function requestRolesList() {
  return request({
    method: 'get',
    url: `/admin/sysAuth/role/findAllRoles`
  })
}

// 获取角色列表分页
export function requestRolesByPage(info) {
  return request({
    method: 'get',
    url: `/admin/sysAuth/role/findRolesByPage/${info.start}/${info.limit}`
  })
}

// 新增角色
export function addRole(data) {
  return request({
    method: 'post',
    url: `/admin/sysAuth/role/saveRolePermissions`,
    data
  })
}

//  更新角色
export function updataRole(data) {
  return request({
    method: 'put',
    url: `/admin/sysAuth/role/updateRolePermissions`,
    data
  })
}

// 删除角色
export function deleteRole(id) {
  return request({
    method: 'delete',
    url: `/admin/sysAuth/role/removeRole/${id}`
  })
}

// 获取角色详情
export function requestRoleInfo(id) {
  return request({
    method: 'get',
    url: `/admin/sysAuth/role/${id}`
  })
}

// 查询所有菜单
export function requestAllPermissions() {
  return request({
    method: 'get',
    url: `/admin/sysAuth/permission/findAllPermissions`
  })
}

// 初始化菜单
export function saveInitMenus(data) {
  return request({
    method: 'POST',
    url: `/admin/sysAuth/permission/saveInitMenus`,
    data
  })
}
